package com.func.domain.strategy.service.rule.tree.factory;

import com.func.domain.strategy.model.valobj.RuleLogicCheckTypeVO;
import com.func.domain.strategy.model.valobj.RuleTreeVO;
import com.func.domain.strategy.service.rule.tree.ILogicTreeNode;
import com.func.domain.strategy.service.rule.tree.factory.engine.IDecisionTreeEngine;
import com.func.domain.strategy.service.rule.tree.factory.engine.impl.DecisionTreeEngine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @version 1.0
 * @className DefaultTreeFactory
 * @description 规则树创建工厂
 * @author: func
 * @date 2025/2/28 21:08
 */

@Slf4j
@Service
@AllArgsConstructor
public class DefaultTreeFactory {
    // 构造注入
    Map<String, ILogicTreeNode> logicTreeNodeGroup;

    public final IDecisionTreeEngine openLogicTree(RuleTreeVO ruleTreeNodVO){
        return new DecisionTreeEngine(ruleTreeNodVO, logicTreeNodeGroup);
    }

    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    @Builder
    public static class TreeActionEntity {
        private RuleLogicCheckTypeVO ruleLogicCheckType;
        private StrategyAwardVO strategyAwardVO;
    }


    @AllArgsConstructor
    @NoArgsConstructor
    @Data
    @Builder
    public static class StrategyAwardVO {
        /** 奖品ID*/
        private Integer awardId;
        /** 奖品的内容, 是award_config的值*/
        private String awardRuleValue;
        // 奖品在前端页面的位置
        private Integer sort;
    }
}
